package Code;

import java.util.HashSet;
import java.util.Set;

public class Code3 {
    static int longestStr(String s){
        Set<Character> set= new HashSet<>();
        int n = s.length();
        char[] c = s.toCharArray();
        int res = 0;
        int l = 0, r= 0;
        for( ; r<n; r++){
            char cur = c[r];
            while(set.contains(cur)){
                set.remove(c[l]);
                l++;
            }
            set.add(cur);
            res = Math.max(res, r- l +1);
        }
        return res;

    }
    public static void main(String[] args) {
        System.out.println(longestStr("bbbbb"));
    }
}
